home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2207 / 2207.xpi / chrome / cooliris.jar / content / cooliris / coolirisStackHandler.js < prev    next >
Text File  |  2010-01-28  |  15KB  |  383 lines

  1. var cpvw_stackManager={hasStack:false,tabStackCount:0,stackMode:"icon",maxWidth:100,arrCanvas:[],arrHidFrames:[],_stackHeight:225,stackShowTimer:null,stackHideTimer:null,isLocked:false,canvasTimeStamp:-1,prevUrl:"",resizeStack:false,previewMouseOver:false,stackHeight:function(){
  2. return this._stackHeight;
  3. },setStackHeight:function(_1){
  4. this._stackHeight=_1;
  5. },objBrowser:function(){
  6. return cpvw_get("browser").boxObject;
  7. },currentTab:function(){
  8. return getBrowser().selectedTab;
  9. },displayStack:function(_2){
  10. if(_2){
  11. if(!cpvw_stackManager.isLocked){
  12. cpvw_stackManager.stackMode="icon";
  13. }
  14. }
  15. cpvw_get("cooliris_stackIcon").hidden=true;
  16. cpvw_get("cooliris_canvasHolder").hidden=true;
  17. cpvw_stackManager.tabStackCount=this.arrCanvas.length;
  18. if(cpvw_stackManager.tabStackCount>0){
  19. setTimeout(function(){
  20. if(cpvw_stackManager.stackMode=="icon"){
  21. cpvw_stackManager.showStackIcon();
  22. }
  23. if(cpvw_stackManager.stackMode=="stack"){
  24. cpvw_stackManager.openStack();
  25. }
  26. },100);
  27. }else{
  28. if(cpvw_stackManager.tabStackCount==0){
  29. getBrowser().selectedTab.removeAttribute("coolirispreviews_dispStack");
  30. cpvw_get("cooliris_canvasHolder").hidden=true;
  31. cpvw_get("cooliris_stackIcon").hidden=true;
  32. }
  33. }
  34. for(var i=0;i<this.arrCanvas.length;i++){
  35. this.arrCanvas[i].style.display="block";
  36. }
  37. },openStack:function(){
  38. if(cpvw_stackManager.hWebControl){
  39. cpvw_stackManager.hWebControl.stop=true;
  40. }
  41. cpvw_get("cooliris_stackIcon").hidden=false;
  42. cpvw_get("cooliris_canvasHolder").hidden=false;
  43. var _4=new cooliris_wc_Point(cpvw_stackManager.objBrowser().width-19,cpvw_stackManager.objBrowser().y+50);
  44. var _5=new cooliris_wc_Dim(100,100);
  45. var _6;
  46. if(!cpvw_stackManager.resizeStack){
  47. _6=150;
  48. _6+=(cpvw_stackManager.tabStackCount-1)*(cpvw_stackManager.maxWidth+20);
  49. if(_6<225){
  50. _6=227;
  51. }
  52. }else{
  53. _6=cpvw_stackManager.stackHeight();
  54. }
  55. if(cpvw_get("cooliris_canvasHolder").boxObject.y+_6>cpvw_stackManager.objBrowser().y+cpvw_stackManager.objBrowser().height-20){
  56. _6=cpvw_stackManager.objBrowser().y+cpvw_stackManager.objBrowser().height-20-cpvw_get("cooliris_canvasHolder").boxObject.y;
  57. }
  58. cpvw_stackManager.setStackHeight(_6);
  59. if(cpvw_get("cooliris_canvasHolder_stack")){
  60. cpvw_get("cooliris_canvasHolder_stack").style.height=1+"px";
  61. }
  62. cpvw_get("cooliris_cHolder").style.maxHeight=(_6-25)+"px";
  63. if(cpvw_stackManager.isLocked){
  64. if(cpvw_stackManager.stackHideTimer){
  65. clearTimeout(cpvw_stackManager.stackHideTimer);
  66. cpvw_stackManager.stackHideTimer=null;
  67. }
  68. cpvw_get("cooliris_stackIcon").hidden=false;
  69. cpvw_get("cooliris_canvasHolder").hidden=false;
  70. _4=new cooliris_wc_Point(cpvw_stackManager.objBrowser().width-118,cpvw_stackManager.objBrowser().y+30);
  71. _5=new cooliris_wc_Dim(118,cpvw_stackManager.stackHeight());
  72. }
  73. getBrowser().selectedTab.setAttribute("coolirispreviews_dispStack","show");
  74. var _7=118;
  75. if(getBrowser().mCurrentBrowser.contentWindow.scrollMaxY!=0){
  76. _7=136;
  77. }
  78. cpvw_stackManager.sWebControl=new cooliris_wc_clsWebControl(cpvw_get("cooliris_canvasHolder"),_4,new cooliris_wc_Point(cpvw_stackManager.objBrowser().width-_7,cpvw_stackManager.objBrowser().y+30),"magnifystack");
  79. cpvw_stackManager.sWebControl.setDim(_5,new cooliris_wc_Dim(118,cpvw_stackManager.stackHeight()));
  80. cpvw_stackManager.sWebControl.maxTimes=30;
  81. cpvw_stackManager.sWebControl.callback=function(_8){
  82. if(_8<cpvw_stackManager.sWebControl.maxTimes/2){
  83. cpvw_get("cooliris_stackTabIcon").hidden=true;
  84. cpvw_get("cooliris_stackTabShow").hidden=false;
  85. cpvw_get("cooliris-stackresize").hidden=false;
  86. cpvw_get("cooliris-stackresize").style.top=(cpvw_get("cooliris_canvasHolder").boxObject.y+cpvw_get("cooliris_canvasHolder").boxObject.height-5)+"px";
  87. cpvw_get("cooliris-stackresize").style.left=cpvw_get("cooliris_canvasHolder").boxObject.x+"px";
  88. }
  89. if(cpvw_get("cooliris_canvasHolder_stack")){
  90. cpvw_get("cooliris_canvasHolder_stack").style.height=(cpvw_get("cooliris_canvasHolder").boxObject.height-1)+"px";
  91. }
  92. cpvw_get("cooliris_cHolder").hidden=false;
  93. cpvw_stackManager.setStackPos(cpvw_get("cooliris_canvasHolder").boxObject.x-19,cpvw_stackManager.objBrowser().y+50,-1,-1);
  94. cpvw_stackManager.previewMouseOver=false;
  95. if(cpvw_get("cooliris-preview-overlay").boxObject.x+cpvw_get("cooliris-preview-overlay").boxObject.width>cpvw_get("cooliris_canvasHolder").boxObject.x-19){
  96. cpvw_previewHandler.changeDimensions(cpvw_get("cooliris-preview-overlay").boxObject.x,cpvw_get("cooliris-preview-overlay").boxObject.y,cpvw_get("cooliris_canvasHolder").boxObject.x-21,cpvw_get("cooliris-preview-overlay").boxObject.height,true);
  97. }
  98. };
  99. setTimeout(function(){
  100. cpvw_stackManager.sWebControl.magnifyStack();
  101. },0);
  102. },addToStack:function(_9,_a,_b){
  103. this.hasStack=true;
  104. var _c=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  105. _c.spec=_a;
  106. if(!_c.schemeIs("http")&&!_c.schemeIs("https")){
  107. return;
  108. }
  109. var _d=this.maxWidth;
  110. var _e=(cpvw_stackManager.objBrowser().height-60)/_d;
  111. var _f=(new Date()).getTime();
  112. if(_9==null){
  113. var _10=document.createElement("iframe");
  114. _10.setAttribute("type","content");
  115. _10.setAttribute("src",_a);
  116. _10.setAttribute("style","width:800px;height:800px");
  117. _10.setAttribute("id","cooliris_stackIframe"+_f);
  118. cpvw_get("cooliris_hidFrames").appendChild(_10);
  119. var _11=function(evt){
  120. var _13=this;
  121. _10.removeEventListener("load",_11,true);
  122. setTimeout(function(){
  123. cpvw_stackManager.addToStack(_13.contentWindow,_13.getAttribute("src"),_13);
  124. },100);
  125. };
  126. _10.addEventListener("load",_11,true);
  127. return;
  128. }
  129. var _14,_15;
  130. if(_9.innerWidth<100){
  131. _14=_9.innerWidth+_9.scrollMaxX;
  132. _15=_9.innerHeight+_9.scrollMaxY;
  133. }else{
  134. _14=_9.innerWidth;
  135. _15=_9.innerHeight;
  136. }
  137. var _16,_17;
  138. if(_14>_15){
  139. _16=_d;
  140. _17=Math.ceil(_d*_15/_14);
  141. }else{
  142. _16=Math.ceil(_d*_14/_15);
  143. _17=_d;
  144. }
  145. cpvw_stackManager.prevUrl=_a;
  146. var _18=document.getElementById("cooliris_canvas");
  147. var _19=_18.cloneNode(true);
  148. var _f=(new Date()).getTime();
  149. _19.setAttribute("id","coolirispreviews_"+_f);
  150. _19.setAttribute("url",_a);
  151. _19.setAttribute("canvasTimeStamp",_f);
  152. _19.setAttribute("hidden",false);
  153. _19.setAttribute("class","cooliris-stack-element");
  154. cpvw_stackManager.arrCanvas.push(_19);
  155. _19.addEventListener("mouseover",function(evt){
  156. var _1b=this.getAttribute("url");
  157. conDump("stack href = "+_1b);
  158. if(cpvw_docHandler.isShowingPreview){
  159. cpvw_docHandler.mouseoverIconTimer=setTimeout(function(){
  160. cpvw_docHandler.initPreviewShow(evt,_1b,null,true);
  161. },cpvw_Delays.PREVIEW_ON_ICON_DELAY);
  162. }
  163. },true);
  164. _19.addEventListener("click",function(evt){
  165. var _1d=this.getAttribute("url");
  166. if(!cpvw_docHandler.isShowingPreview){
  167. cpvw_docHandler.openDelayTime=100;
  168. cpvw_docHandler.dispDelayTime=500;
  169. cpvw_docHandler.screenX=document.getElementById("appcontent").boxObject.width-10;
  170. cpvw_docHandler.initPreviewShow(evt,_1d,null,true);
  171. }else{
  172. cpvw_docHandler.initPreviewShow(evt,_1d,null,true);
  173. }
  174. },true);
  175. if(this.stackMode=="icon"){
  176. cpvw_get("cooliris_stackIcon").hidden=true;
  177. cpvw_get("cooliris_canvasHolder").hidden=false;
  178. cpvw_get("cooliris_cHolder").hidden=false;
  179. cpvw_get("cooliris_canvasHolder").style.top=(cpvw_stackManager.objBrowser().y+50)+"px";
  180. cpvw_get("cooliris_canvasHolder").style.left=(cpvw_stackManager.objBrowser().width+50)+"px";
  181. cpvw_get("cooliris_canvasHolder").style.width="0px";
  182. cpvw_get("cooliris_canvasHolder").style.height="0px";
  183. }
  184. cpvw_get("cooliris_cHolder").appendChild(_19);
  185. _19.width=_16;
  186. _19.height=_17;
  187. var ctx=_19.getContext("2d");
  188. ctx.save();
  189. ctx.scale(_16/_14,_17/_15);
  190. ctx.drawWindow(_9,0,0,_14,_15,"rgb(255,255,255)");
  191. ctx.restore();
  192. var _1f=_19.cloneNode(true);
  193. var _20=_1f.getContext("2d");
  194. _20.save();
  195. _20.scale(_16/_14,_17/_15);
  196. _20.drawWindow(_9,0,0,_14,_15,"rgb(255,255,255)");
  197. _20.restore();
  198. cpvw_get("cooliris_animFrame_stack").appendChild(_1f);
  199. if(cpvw_previewHandler.dimPreview!=null){
  200. var _21=new cooliris_wc_Point(cpvw_previewHandler.dimPreview.left,cpvw_previewHandler.dimPreview.top);
  201. }else{
  202. var _21=new cooliris_wc_Point(250,250);
  203. }
  204. cpvw_get("cooliris_animFrame").style.display="block";
  205. var _22=new cooliris_wc_clsWebControl(cpvw_get("cooliris_animFrame"),_21,new cooliris_wc_Point(cpvw_get("cooliris_canvasHolder").boxObject.x,cpvw_get("cooliris_canvasHolder").boxObject.y),"magnify");
  206. _22.setDim(new cooliris_wc_Dim(_16,_17),new cooliris_wc_Dim(_16,_17));
  207. _22.callback=function(_23){
  208. if(_23==0){
  209. if(cpvw_stackManager.stackMode=="icon"){
  210. cpvw_get("cooliris_canvasHolder").hidden=true;
  211. }
  212. cpvw_get("cooliris_animFrame_stack").removeChild(_1f);
  213. cpvw_get("cooliris_animFrame").style.display="none";
  214. if(_b!=null){
  215. cpvw_get("cooliris_hidFrames").removeChild(_b);
  216. }
  217. }
  218. };
  219. _22.maxTimes=30;
  220. setTimeout(function(){
  221. _22.magnifyStack();
  222. },0);
  223. this.tabStackCount++;
  224. if(this.stackMode=="icon"){
  225. this.showStackIcon();
  226. }else{
  227. this.displayStack();
  228. }
  229. },onStackMouseover:function(){
  230. if(cpvw_stackManager.stackHideTimer){
  231. clearTimeout(cpvw_stackManager.stackHideTimer);
  232. cpvw_stackManager.stackHideTimer=null;
  233. }
  234. if(!cpvw_stackManager.stackShowTimer&&cpvw_stackManager.stackMode=="icon"&&!cpvw_stackManager.isLocked){
  235. cpvw_stackManager.stackShowTimer=setTimeout("cpvw_stackManager.stackMode = \"stack\";cpvw_stackManager.displayStack()",300);
  236. }
  237. },onStackMouseout:function(){
  238. if(cpvw_stackManager.stackShowTimer){
  239. clearTimeout(cpvw_stackManager.stackShowTimer);
  240. cpvw_stackManager.stackShowTimer=null;
  241. }
  242. if(cpvw_stackManager.stackHideTimer==null&&cpvw_stackManager.stackMode=="stack"&&!cpvw_stackManager.isLocked&&cpvw_stackManager.arrCanvas.length>0){
  243. cpvw_stackManager.stackHideTimer=setTimeout("cpvw_stackManager.stackMode = \"icon\";cpvw_stackManager.hideStack()",1000);
  244. }
  245. },hideStack:function(){
  246. if(cpvw_stackManager.sWebControl){
  247. cpvw_stackManager.sWebControl.stop=true;
  248. }
  249. cpvw_get("cooliris-stackresize").hidden=true;
  250. cpvw_stackManager.hWebControl=new cooliris_wc_clsWebControl(cpvw_get("cooliris_canvasHolder"),new cooliris_wc_Point(cpvw_get("cooliris_canvasHolder").boxObject.x,cpvw_get("cooliris_canvasHolder").boxObject.y),new cooliris_wc_Point(cpvw_stackManager.objBrowser().width-19,cpvw_stackManager.objBrowser().y+50),"magnifystack");
  251. cpvw_stackManager.hWebControl.setDim(new cooliris_wc_Dim(cpvw_get("cooliris_canvasHolder").boxObject.width,cpvw_get("cooliris_canvasHolder").boxObject.height),new cooliris_wc_Dim(19,57));
  252. cpvw_stackManager.hWebControl.maxTimes=30;
  253. cpvw_stackManager.hWebControl.callback=function(_24){
  254. if(!cpvw_get("cooliris_canvasHolder").hidden){
  255. cpvw_stackManager.setStackPos(cpvw_get("cooliris_canvasHolder").boxObject.x-19,cpvw_stackManager.objBrowser().y+50,-1,-1);
  256. }
  257. if(_24==cpvw_stackManager.hWebControl.maxTimes/2){
  258. cpvw_get("cooliris_stackTabIcon").hidden=false;
  259. cpvw_get("cooliris_stackTabShow").hidden=true;
  260. cpvw_get("cooliris_cHolder").hidden=true;
  261. }else{
  262. if(_24==0){
  263. cpvw_get("cooliris_canvasHolder").hidden=true;
  264. if(cpvw_stackManager.tabStackCount>0){
  265. cpvw_stackManager.showStackIcon();
  266. }
  267. getBrowser().selectedTab.removeAttribute("coolirispreviews_dispStack");
  268. if(!cpvw_stackManager.previewMouseOver){
  269. cpvw_docHandler.initPreviewHide();
  270. }
  271. }
  272. }
  273. };
  274. setTimeout(function(){
  275. cpvw_stackManager.hWebControl.magnifyStack();
  276. },0);
  277. cpvw_stackManager.stackMode="icon";
  278. },showStackIcon:function(){
  279. cpvw_get("cooliris_stackIcon").style.position="fixed";
  280. cpvw_get("cooliris_stackIcon").style.zIndex=1000;
  281. cpvw_get("cooliris_stackIcon").hidden=false;
  282. cpvw_get("cooliris_stackTabIcon").hidden=false;
  283. cpvw_get("cooliris_stackTabShow").hidden=true;
  284. var _25=19;
  285. if(getBrowser().mCurrentBrowser.contentWindow.scrollMaxY!=0){
  286. _25=36;
  287. }
  288. this.setStackPos(cpvw_get("browser").boxObject.width-_25,cpvw_get("browser").boxObject.y+50,20,57);
  289. },setStackPos:function(_26,top,_28,_29){
  290. if(_26!=-1){
  291. cpvw_get("cooliris_stackIcon").style.left=_26+"px";
  292. }
  293. if(top!=-1){
  294. cpvw_get("cooliris_stackIcon").style.top=top+"px";
  295. }
  296. if(_28!=-1){
  297. cpvw_get("cooliris_stackIcon").style.width=_28+"px";
  298. }
  299. if(_29!=-1){
  300. cpvw_get("cooliris_stackIcon").style.height=_29+"px";
  301. }
  302. },lockStack:function(){
  303. if(cpvw_stackManager.isLocked){
  304. cpvw_stackManager.isLocked=false;
  305. cpvw_get("cooliris_stackLocked").setAttribute("locked","false");
  306. getBrowser().selectedTab.setAttribute("coolirispreviews_dispStack","hide");
  307. if(cpvw_stackManager.stackShowTimer){
  308. clearTimeout(cpvw_stackManager.stackShowTimer);
  309. cpvw_stackManager.stackShowTimer=null;
  310. }
  311. }else{
  312. cpvw_stackManager.isLocked=true;
  313. cpvw_get("cooliris_stackLocked").setAttribute("locked","true");
  314. getBrowser().selectedTab.setAttribute("coolirispreviews_dispStack","show");
  315. if(cpvw_stackManager.stackHideTimer){
  316. clearTimeout(cpvw_stackManager.stackHideTimer);
  317. cpvw_stackManager.stackHideTimer=null;
  318. }
  319. }
  320. },startResize:function(evt){
  321. cpvw_stackManager.curMouseLocY=evt.screenY;
  322. document.getElementById("main-window").addEventListener("mouseup",cpvw_stackManager.stopResize,true);
  323. document.getElementById("main-window").addEventListener("mousemove",cpvw_stackManager.doResize,true);
  324. },stopResize:function(evt){
  325. var _2c=cpvw_stackManager.stackHeight()+evt.screenY-cpvw_stackManager.curMouseLocY;
  326. if(_2c<225){
  327. _2c=227;
  328. }
  329. if(cpvw_get("cooliris_canvasHolder").boxObject.y+_2c>cpvw_stackManager.objBrowser().y+cpvw_stackManager.objBrowser().height-20){
  330. _2c=cpvw_stackManager.objBrowser().y+cpvw_stackManager.objBrowser().height-20-cpvw_get("cooliris_canvasHolder").boxObject.y;
  331. }
  332. cpvw_stackManager.setStackHeight(_2c);
  333. if(cpvw_get("cooliris_canvasHolder_stack")){
  334. cpvw_get("cooliris_canvasHolder_stack").style.height=_2c+"px";
  335. }
  336. cpvw_get("cooliris_cHolder").style.maxHeight=(_2c-25)+"px";
  337. cpvw_stackManager.resizeStack=true;
  338. document.getElementById("main-window").removeEventListener("mouseup",cpvw_stackManager.stopResize,true);
  339. document.getElementById("main-window").removeEventListener("mousemove",cpvw_stackManager.doResize,true);
  340. },doResize:function(evt){
  341. var _2e=cpvw_stackManager.stackHeight()+evt.screenY-cpvw_stackManager.curMouseLocY;
  342. if(_2e<225||(cpvw_get("cooliris_canvasHolder").boxObject.y+_2e>cpvw_stackManager.objBrowser().y+cpvw_stackManager.objBrowser().height-20)){
  343. return;
  344. }
  345. cpvw_get("cooliris_canvasHolder").style.height=_2e+"px";
  346. cpvw_get("cooliris-stackresize").style.top=(cpvw_get("cooliris_canvasHolder").boxObject.y+cpvw_get("cooliris_canvasHolder").boxObject.height-5)+"px";
  347. if(cpvw_get("cooliris_canvasHolder_stack")){
  348. cpvw_get("cooliris_canvasHolder_stack").style.height=_2e+"px";
  349. }
  350. cpvw_get("cooliris_cHolder").style.height=(_2e-25)+"px";
  351. },closeStack:function(){
  352. var _2f=cpvw_stackManager.arrCanvas;
  353. for(var i=0;i<_2f.length;i++){
  354. cpvw_get("cooliris_cHolder").removeChild(_2f[i]);
  355. _2f.splice(i,1);
  356. i--;
  357. }
  358. getBrowser().selectedTab.removeAttribute("coolirispreviews_dispStack");
  359. if(cpvw_stackManager.stackHideTimer){
  360. clearTimeout(cpvw_stackManager.stackHideTimer);
  361. cpvw_stackManager.stackHideTimer=null;
  362. }
  363. cpvw_get("cooliris_canvasHolder").hidden=true;
  364. cpvw_get("cooliris_stackIcon").hidden=true;
  365. },removeFromStack:function(){
  366. var _31=document.popupNode.getAttribute("canvasTimeStamp");
  367. var _32=cpvw_stackManager.arrCanvas;
  368. for(var i=0;i<_32.length;i++){
  369. var _34=_32[i].getAttribute("canvasTimeStamp");
  370. if(_31==_34){
  371. cpvw_get("cooliris_cHolder").removeChild(_32[i]);
  372. _32.splice(i,1);
  373. cpvw_stackManager.tabStackCount--;
  374. }
  375. }
  376. if(cpvw_stackManager.tabStackCount==0){
  377. getBrowser().selectedTab.removeAttribute("coolirispreviews_dispStack");
  378. cpvw_get("cooliris_canvasHolder").hidden=true;
  379. cpvw_get("cooliris_stackIcon").hidden=true;
  380. }
  381. }};
  382.  
  383.